﻿@using System.Collections
@using Projectmanagement.Entity
@using ProjectManagement.Models
@using Projectmanagement.Utl
@model IQueryable<Project>
@{
    ViewBag.Title = "Task";
    string type = ViewBag.type;
 
}
@*@Html.Hidden("jibie", Employee.CurrentRoleLVL)
@Html.Hidden("hidProject")
@Html.Hidden("hidMember")
@Html.Hidden("hidTaskCode")*@
<style type="text/css">
    #OverdueTask
    {
        margin-top: 9px;
    }
    .group_head
    {
        width: 1057px;
        height: 120px;
    }
    .left1
    {
        width: 190px;
        float: left;
    }
    .left2
    {
        width: 250px;
        float: left;
        margin-left: 22;
    }
    .left3
    {
        width: 250px;
        float: left;
        margin-left: 22;
    }
    .left4
    {
        width: 250px;
        float: left;
        margin-left: 22;
    }
    .group_head lable
    {
        font-size: 0.8em;
    }
    .group_head fieldset
    {
        border: 1px solid #fff;
        padding: 0 0 10px 0;
        margin: 0;
    }
    .group_head fieldset legend
    {
        font-size: 16px;
        font-family: inherit;
    }
</style>
@(Html.Telerik().Grid<_Task>()
        .Name("OverdueTask").HtmlAttributes(new { @class = "taskindex" })
    .DataKeys(keys => { keys.Add(item => item.ID); })
    .ClientEvents(events => events.OnEdit("onEdit")
                .OnDataBinding("Grid_onDataBinding")
        //    .OnLoad("Grid3_onLoad")
            )
    .ToolBar(toolBar => toolBar.Template(
                                    @<text>
<div class="group_head">
    <fieldset>
        <legend>所有任务</legend>
        <div style="height: 50px; margin: 0 0 0 50px;">
            <div class="left1">
                @Html.Partial("_ProjectMemberFilter")
            </div>
            <div class="left3">
                <label>
                    任务名称：</label>@Html.TextBox("txtName", "", new { style = "width:145px;" })<br />
                <label>
                    任务编号：</label>@Html.TextBox("txtTaskCode", "", new { style = "width:145px;" })
            </div>
            <div class="left2">
                <label>
                    开始时间:</label>
                @(Html.Telerik().DatePicker().Name("StartDate").HtmlAttributes(new { style = "width:145px;font-size: 0.8em;" }))<br />
                <label style="margin-top: 5px;">
                    结束时间:</label>
                @(Html.Telerik().DatePicker().Name("EndDate").HtmlAttributes(new { style = "width:145px;font-size: 0.8em;margin-top: 4px;" }))
            </div>
            <div class="left4">
                <label>
                    任务状态：</label>
                @Html.DropDownList("ddlTaskState", new SelectList(CH.GetAllDatas<TaskState>(), "ID", "Name"), "-请选择-", new { style = "width:145px;" })
            </div>
        </div>
        <div style="margin-left: 920px;">
            <input type="button" id="btnSearch" value="查询" style="width: 80px; height: 30px;"
                onclick="btnSearch()" /></div>
    </fieldset>
</div>
</text>
                                                                                         ))
                                                         .DataBinding(dataBinding =>
                                                         {
                                                             dataBinding.Ajax()
                                                                 .Select("_SelectAllTaskIndex", "AllTask")
                                                                 .Insert("_InsertAjaxEditing", "Task");
                                                         })
                                                         .Columns(columns =>
                                                         {
                                                             columns.Bound(item => item.Ttype).Hidden();
                                                             columns.Bound(item => item.ProjectCode);
                                                             columns.Bound(item => item.TaskCode);
                                                             columns.Bound(item => item.Name).Width(240);
                                                             columns.Bound(item => item.TaskStateName).Width(140);
                                                             columns.Bound(item => item.StartDate).Width(140);
                                                             columns.Bound(item => item.EndDate).Width(140);
                                                             columns.Bound(item => item.Duration).Width(120);
                                                             columns.Bound(item => item.Owners).Width(140);

                                                             columns.Bound(item => item.Assinger).Width(120);
                                                             columns.Bound(c => c.ID)
                                                                     .ClientTemplate("<a class='t-button' onclick='showtask(<#= ID #>)'>编辑</a>")
                                                                     .Title("操作").Width(100);
                                                         })
                                                         .Editable(editing => editing.Mode(GridEditMode.PopUp))
                                                         .Pageable(paging => paging.Style(GridPagerStyles.Status).PageOnScroll(true))
                                                         .Scrollable(c => c.Height("353px"))
                                                         .Sortable()
                                                         .Resizable(resizing => resizing.Columns(true))
                                                           )
@(Html.Telerik().Window()
    .Name("ChangeState")
    .Visible(false)
    .Title("变更状态")
    .Modal(true)
    .Width(500)
    .Draggable(true)
    .Height(400)
    .Content(@<text>
<div id="ChangeState-details">
    <input type="hidden" name="tid" />
    <table class="noline" style="width: 100%;">
        <tr>
            <td style="width: 100px;">
                任务名称
            </td>
            <td class="taskname">
            </td>
        </tr>
        <tr>
            <td style="width: 100px;">
                任务执行人
            </td>
            <td class="taskowners">
            </td>
        </tr>
        <tr>
            <td style="width: 100px;">
                任务说明
            </td>
            <td class="taskcontent">
            </td>
        </tr>
        <tr>
            <td style="width: 100px;">
                知识库链接
            </td>
            <td class="taskKMLinks">
            </td>
        </tr>
        <tr>
            <td style="width: 100px;">
                可交付成果
            </td>
            <td class="taskDeliverables">
            </td>
        </tr>
        <tr>
            <td style="width: 100px;">
                状态选择
            </td>
            <td>
                <select name="sid" onchange="changestate(this)">
                </select>
                <select name="toname">
                </select>
            </td>
        </tr>
        <tr>
            <td>
                说明
            </td>
            <td>
                <textarea style="width: 100%; height: 100px;" name="des"></textarea>
            </td>
        </tr>
    </table>
    <div style="text-align: right;">
        <a class="t-button" onclick="submitchangestate()">确定</a>
    </div>
</div>
</text>)
      )
<script type="text/javascript">
    function showtask(id) {
        $.post('Task/GetDetail/', { taskid: id }, function (result) {
            $('.TastMessageAll-wrapper').html(result);
            var window = $('#TastMessageAll').data('tWindow');
            window.center().open();
        });
    }

    function btnSearch() {
        $("#OverdueTask").data("tGrid").rebind();
    }

    function Grid_onDataBinding(e) {
        var projectid = $("#projectfilter").val();
        var member = $('#memberfilter option:selected').text();
        var name = $("#txtName").val();
        var state = $("#ddlTaskState").val();
        var start = $("#StartDate").val();
        var end = $("#EndDate").val();
        var taskCode = $("#txtTaskCode").val();
        e.data = {
            projectid: projectid,
            member: member,
            name: name,
            state: state,
            start: start,
            end: end,
            taskCode: taskCode
        };
    }

    function onEdit(e) {
        var taskId = e.dataItem["ID"];
        if (taskId == 0) {
            $("input[name=Owners]").hide();
            $("input[name=Owners]").after($("input[name=Owners]").val());
            $("#comment").hide();
        } else {
            $("#legendTitle").html("编辑任务");
            $("input[name=Owners]").hide();
            $("input[name=Owners]").after($("input[name=Owners]").val());
            $("#Name").attr("disabled", "disabled");
            $("#TaskStateID").attr("disabled", "disabled");
            $("select[name=ProjectID]").hide();
            $("select[name=ProjectID]").after($("select[name=ProjectID] option:selected").text());
            $.post('/Task/GetCommentList', { taskid: taskId }, function (result) {
                $('#commentList').html(result);
            });
        }
    }

    $(document).ready(function () {
        initialProjectMemberfilter();
    });

    function dtonChange(e) {
        $("form").submit();
    }
</script>
@(Html.Telerik().Window().Title("任务信息")
    .Name("TastMessageAll")
    .Content(@<text><div class="dialogue-TastMessageAll">
        <div class="TastMessageAll-wrapper">
        </div>
    </div></text>)
    .Width(1050)
    .Height(550)
    .Modal(true).Visible(false).Draggable(true)
)